<template>
  <div class="RgProdSeedRecord">
    <div class="publicSearch">
      <div class="searchBar" :style="{ height: isMoreSearch ? 'auto' : '' }">
        <el-button-group>
          <el-button @click="getRgProdSeedRecordData" size="mini" icon="el-icon-search">查询</el-button>
          <el-button @click="clearSearchData" size="mini" icon="el-icon-refresh">重置</el-button>
        </el-button-group>

        <div>
          <span>履约号查询</span>
          <el-input v-model="searchData.agreementNo" size="mini" placeholder="履约号" clearable></el-input>
        </div>

        <div>
          <span>序号查询</span>
          <el-input v-model="searchData.packingNo" size="mini" placeholder="序号" clearable></el-input>
        </div>

        <div>
          <span>产品编号查询</span>
          <el-input v-model="searchData.sn" size="mini" placeholder="产品编号" clearable></el-input>
        </div>
        <div>
          <span>货物描述查询</span>
          <el-input v-model="searchData.packingName" size="mini" placeholder="货物描述" clearable></el-input>
        </div>
      </div>
    </div>

    <div class="headerBtns">
      <!-- <el-button
        size="small"
        type="primary"
        round
        icon="iconfont icon-xinzeng"
        @click="dialogNewVisible = true"
      >新增</el-button>-->
    </div>

    <div class="tableBox none">
      <el-table
        v-loading="loading.masterTable"
        highlight-current-row
        :data="RgProdSeedRecords"
        style="width: 100%"
        :row-style="Mystyle"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column fixed="left" type="index" width="50"></el-table-column>

        <el-table-column show-overflow-tooltip prop="packingNo" label="序号" min-width="150">
          <template slot-scope="scope">
            <span class="textBtn">
              {{
              scope.row.packingNo
              }}
            </span>
          </template>
        </el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="agreementNo"
          label="履约号"
          min-width="150"
        ></el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="packingName"
          label="货物描述"
          min-width="150"
        ></el-table-column>
        <el-table-column sortable show-overflow-tooltip prop="unitName" label="单位" min-width="150"></el-table-column>

        <el-table-column show-overflow-tooltip prop="status" label="状态" min-width="150">
          <template slot-scope="scope">
            <span class="textBtn">
              {{
              scope.row.status==4000?"出库":"未出库"
              }}
            </span>
          </template>
        </el-table-column>

        <el-table-column sortable show-overflow-tooltip prop="qty" label="数量" min-width="150"></el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="packingCount"
          label="箱数"
          min-width="150"
        ></el-table-column>

        <el-table-column
          sortable
          show-overflow-tooltip
          prop="chartNumber"
          label="图号"
          min-width="150"
        ></el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="projectName"
          label="工程名称"
          min-width="150"
        ></el-table-column>
      </el-table>
      <el-pagination
        style="text-align: right"
        class="pagination-bottom"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
        :page-sizes="[10, 20, 30, 50]"
        :current-page.sync="searchData.pageNum"
        :page-size="searchData.pageSize"
        layout="sizes,total, prev, pager, next, jumper"
        :total="searchData.total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "RgProdSeedRecord",
  data() {
    // 校验规则
    return {
      isMoreSearch: false,
      loading: {
        masterTable: true
      },
      // 用作查询的数据
      searchData: {
        // 仓库编码 获得当前仓库的编码
        wareId: PF.getLocal("wareId", "number"),
        pageNum: 1,
        pageSize: 10,
        total: null,
        // 状态： 0=计划； 1000=生产； 2000=检验； 4000=出库； -1=作废
        status: "",
        // 履约号
        agreementNo: "",
        //  序号
        packingNo: "",
        // 产品编号
        sn: "",
        packingName: ""
      },

      //存放装箱单数据的数组
      RgProdSeedRecords: [],

      formLabelWidth: "120px",
      rowData: {
        //
      },
      Mystyle: { height: "50px" },
      filterText: "",
      defaultProps: {
        children: "children",
        label: "name"
      },
      // 选中的数据
      multipleSelection: []
    };
  },
  computed: {},
  watch: {
    //
  },
  methods: {
    //分页设置每页的条数
    handleSizeChange(val) {
      this.searchData.pageSize = val;
      this.getRgProdSeedRecordData();
    },
    //分页设置从第几条开始
    handleCurrentChange(val) {
      this.searchData.pageNum = val;
      this.getRgProdSeedRecordData();
    },
    // 清空查询条件批次号
    clearSearchData() {
      this.searchData.agreementNo = "";
      this.searchData.packingNo = "";
      this.searchData.sn = "";
      this.searchData.packingName = "";

    },

    getRgProdSeedRecordData() {
      let that = this;
      that.loading.masterTable = true;
      let searchData = JSON.parse(JSON.stringify(this.searchData));
      console.log(searchData);
      IOT.getServerData(
        "/so/masters/rgOutRecordList",
        "get",
        searchData,
        ret => {
          that.loading.masterTable = false;
          if (ret.code === 200) {
            // rows就是返回的数据
            this.RgProdSeedRecords = ret.rows;
            this.searchData.total = ret.total;
            this.searchData.pageNum = ret.pageNumber;
          } else {
            IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
          }
        }
      );
    },
    // 新增的重置
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },

    // 选择总装箱的查询条件的重置
    clearsearchSelectAcceptRecord() {
      this.searchSelectAcceptRecord.keyWords = "";
      this.searchSelectAcceptRecord.itemName = "";
      this.searchSelectAcceptRecord.itemCode = "";
      this.searchSelectAcceptRecord.asnDetailNo = "";
    },
    // 获取总装箱的数据
    getAcceptRecordData() {
      var that = this;
      that.acceptRecords = [];
      that.loading.masterTable = true;
      IOT.getServerData("/accept/records/list", "get", that.searchData, ret => {
        that.loading.masterTable = false;
        if (ret.code === 200) {
          that.acceptRecords = ret.rows;
          that.searchSelectAcceptRecord.total = ret.total;
          that.searchSelectAcceptRecord.pageNum = ret.pageNumber;
        } else {
          IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
        }
      });
    },

    // 选择总装箱数据时
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },

    // 查询总装箱的分页
    handleCurrentChange2(val) {
      this.searchSelectAcceptRecord.pageNum = val;
      this.getAcceptRecordData();
    }
  },
  // 页面加载时刷新
  activated() {
    this.searchData.pageNum = 1;
    this.searchData.pageSize = 10;
    //请求数据
    this.getRgProdSeedRecordData();
  }
};
</script>

<style scoped lang="less">
.RgProdSeedRecord {
}
</style>
